
*set working directory 

set more off

cd"/Users/swang/Dropbox/Replication"



*Install packages if necessary         

*ssc install estout
*ssc install coefplot
*ssc install ivreg2
*ssc install ranktest
*ssc install xtivreg2
*ssc install blindschemes 


***************
* Figure 2                            
***************

use aggregate_data, clear

*--------------
* Left Figure 
*--------------


graph twoway (lowess percentage_hea_main Year if Tier==0, lcolor(gs10) lw(thick)) ///
 (lowess percentage_hea_main Year if Tier==1, lcolor(gs0) lw(thick)) ,xline(2008, lw(thick) lcolor(black)) ///
legend(off  rows(1) size(small) order(1 "Non-quota tier" 2 "Quota tier")) ///
ysca(titlegap(2)) scheme(plottig) ///
xtitle("") ytitle("Proportion  (%)", size(mediumn)) title("Health Bills", size(mediumn)) ///
xlabel(, labsize(mediumn)) ylabel(, labsize(mediumn)) xsca(titlegap(2)) aspectratio(1) 

graph save "Fig2hea.gph", replace

		
*--------------
* Middle Figure 
*--------------

graph twoway (lowess percentage_wel_main Year if Tier==0, lcolor(gs10) lw(thick)) ///
 (lowess percentage_wel_main Year if Tier==1,lcolor(gs0) lw(thick)),xline(2008, lw(thick) lcolor(black)) ///
legend(off) ysca(titlegap(2)) scheme(plottig) ///
xtitle("") ytitle("Proportion  (%)", size(mediumn)) title("Welfare Bills", size(mediumn)) ///
xlabel(, labsize(mediumn)) ylabel(, labsize(mediumn)) xsca(titlegap(2)) aspectratio(1) 

graph save "Fig2soc.gph", replace


*-------------
* Right Figure 
*-------------

graph twoway (lowess percentage_edu_main Year if Tier==0, lcolor(gs10) lw(thick)) ///
 (lowess percentage_edu_main Year if Tier==1,lcolor(gs3) lw(thick)),xline(2008, lw(thick) lcolor(black)) ///
legend(off) ysca(titlegap(2)) scheme(plottig) ///
xtitle("") ytitle("Proportion  (%)", size(mediumn)) title("Education Bills", size(mediumn)) ///
xlabel(, labsize(mediumn)) ylabel(, labsize(mediumn)) xsca(titlegap(2)) aspectratio(1) 

graph save "Fig2edu.gph", replace


*-------------
* Combine Figures 
*-------------


grc1leg2 "Fig2hea.gph" "Fig2soc.gph" "Fig2edu.gph", ycommon col(3) pos(6) ring(0) 
gr_edit legend.plotregion1.DragBy 18.02196180995545 -36.31493056442152







***************
* Table 1                            
***************


use ReplicationdataDoWomenRepresentWomenPOBE.dta,clear


gen PRxFemale=PR*Female
gen PostxFemale=Post*Female
gen PRxPost=PR*Post
gen PRxPostxFemale = PR*Post*Female

eststo clear

eststo: reg percentage_wel_main PR Post Female PRxPost  PRxFemale  PostxFemale PRxPostxFemale i.Year i.District, cluster(id) robust 
eststo: reg percentage_hea_main PR Post Female PRxPost  PRxFemale  PostxFemale PRxPostxFemale i.Year i.District, cluster(id) robust 
eststo: reg percentage_edu_main PR Post Female PRxPost  PRxFemale  PostxFemale PRxPostxFemale i.Year i.District, cluster(id) robust 

eststo: reg percentage_wel_main PR Post Female PRxPost  PRxFemale  PostxFemale PRxPostxFemale i.Pid WelfareHealth Education Majority Seniority Age Indigenous PhD MD z2AverageHHIncome Rural i.AdminDivision i.Year i.District, cluster(id) robust 
est store DID1 
eststo: reg percentage_hea_main PR Post Female PRxPost  PRxFemale  PostxFemale PRxPostxFemale i.Pid WelfareHealth Education Majority Seniority Age Indigenous PhD MD z2AverageHHIncome Rural i.AdminDivision i.Year i.District, cluster(id) robust 
est store DID2
eststo: reg percentage_edu_main PR Post Female PRxPost  PRxFemale  PostxFemale PRxPostxFemale i.Pid WelfareHealth Education Majority Seniority Age Indigenous PhD MD z2AverageHHIncome Rural i.AdminDivision i.Year i.District, cluster(id) robust 
est store DID3



esttab using Table1.tex, replace ///
       nobaselevels compress modelwidth(6) keep(PRxPost PostxFemale PRxPostxFemale) ///
       stats(N, fmt(%9.0g) labels("Observations")) booktabs ///
       title(Extended Difference-in-Differences Analysis: Effect of Quotas (Comparing between Tiers and Gender)) b(3) se(3) ///
       indicate("Individual controls = *.Pid WelfareHealth* Education* Majority* Seniority* Age* Indigenous* PhD* MD*" ///
	   "District controls = z2AverageHHIncome* Rural* *.AdminDivision" "District dummies = *.District" "Year dummies = *.Year") ///
       star(+ 0.10 * 0.05 ** 0.01 *** 0.001) mtitles(Welfare Health Education Welfare Health Education) ///
       label eqlabels(none) varlabels(PRxPost "Quota tier $\times$ Post" PostxFemale "Post $\times$ Female" PRxPostxFemale "Quota tier $\times$ Post $\times$ Female")

	   


***************
* Figure 3                            
***************


coefplot ///
(DID1), bylabel(Welfare) || ///
(DID2), bylabel(Health) || ///
(DID3), bylabel(Education) ||, ///
scheme(plottig) level(95 90) msymbol(O) byopts(cols(1) legend(off)) ///
coeflabels(PRxPostxFemale = "Mandate effect" PostxFemale = "Gender effect" PRxPost = "Spillover effect") ///
mcolor(black) ciopts(lcolor(black black)) ///
ylabel(, notick labsize(msmall)) xline(0, lw(medthick) lcolor(black)) keep(PRxPostxFemale PRxPost PostxFemale) ///
order(PRxPostxFemale PostxFemale PRxPost)




***************
* Table 2                            
***************


use 2005-2010,replace
xtset id Year

eststo clear
eststo: xtivreg2 percentage_wel_passage_main (Wel_main = Post), cluster(id) r first savefirst savefprefix(first1) fe 
est store IV1

eststo: xtivreg2 percentage_hea_passage_main (Hea_main = Post), cluster(id) r first savefirst savefprefix(first2) fe 
est store IV2

eststo: xtivreg2 percentage_edu_passage_main (Edu_main = Post), cluster(id) r first savefirst savefprefix(first3) fe 
est store IV3



esttab first1* est1 first2* est2 first3* est3 using Table2.tex, ///
  replace label booktabs compress nogaps noconstant nomti nodepvars ///
  b(3) se(3) order(Wel_main Hea_main Edu_main) varwidth(15) modelwidth(7) star(+ 0.10 * 0.05 ** 0.01 *** 0.001)   ///
  stat(N widstat idp, labels("N" "Kleibergen-Paap F stat" "Kleibergen-Paap LM Test p-value")fmt(%9.0g %9.3f %9.3f) ) ///
  title(Panel Data 2SLS-IV Estimation on Social Policy Bill Passage \label{ivest}) note("Robust standard errors in parentheses.") ///
  mgroups("Welfare" "Health" "Education", pattern(1 0 1 0 1 0) ///  
  prefix(\multicolumn{@span}{c}{) suffix	(}) span erepeat(\cmidrule(lr){@span})) ///
  varlabels(Wel_main "N. of welfare bills proposed" Hea_main "N. of health bills proposed" Edu_main "N. of education bills proposed" Post "Post")


  
  
***************
* Figure 4                            
***************

xtivreg2 percentage_wel_passage_main (Wel_main = Post) if Type == 1, cluster(id) fe
est store IVA1
xtivreg2 percentage_hea_passage_main (Hea_main = Post) if Type == 1, cluster(id) fe
est store IVA2
xtivreg2 percentage_edu_passage_main (Edu_main = Post) if Type == 1, cluster(id) fe
est store IVA3


xtivreg2 percentage_wel_passage_main (Wel_main = Post) if Type == 3, cluster(id) fe
est store IVB1
xtivreg2 percentage_hea_passage_main (Hea_main = Post) if Type == 3, cluster(id) fe
est store IVB2
xtivreg2 percentage_edu_passage_main (Edu_main = Post) if Type == 3, cluster(id) fe
est store IVB3



xtivreg2 percentage_wel_passage_main (Wel_main = Post) if Type == 2, cluster(id) fe
est store IVC1
xtivreg2 percentage_hea_passage_main (Hea_main = Post) if Type == 3, cluster(id) fe
est store IVC2
xtivreg2 percentage_edu_passage_main (Edu_main = Post) if Type == 3, cluster(id) fe
est store IVC3


xtivreg2 percentage_wel_passage_main (Wel_main = Post) if Type == 0, cluster(id) fe
est store IVD1
xtivreg2 percentage_hea_passage_main (Hea_main = Post) if Type == 0, cluster(id) fe
est store IVD2
xtivreg2 percentage_edu_passage_main (Edu_main = Post) if Type == 0, cluster(id) fe
est store IVD3


coefplot ///
(IV1)(IV2)(IV3), bylabel(Full panel sample) || ///
(IVA1)(IVA2)(IVA3), bylabel(Quota-elected women) || ///
(IVB1)(IVB2)(IVB3), bylabel(Non-quota-elected women) || ///
(IVC1)(IVC2)(IVC3), bylabel(Men elected to the quota tier) || ///
(IVD1)(IVD2)(IVD3), bylabel(Men elected to the non-quota tier) || , ///
level(95 90) msymbol(O) byopts(cols(1) legend(off)) xline(0, lw(medthick) lcolor(black)) ///
coeflabels(Wel_main = "Welfare" Hea_main = "Health" Edu_main = "Education") ///
mcolor(black) ciopts(lcolor(black black)) yscale(noline) scheme(plottig) ///
ylabel(, notick labsize(msmall)) keep(Wel_main Hea_main Edu_main) xscale(r(-10(1)10)) 

